package com.haoshuang.zhouzhoubang.ui.page.order.rework.rework.personal

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.CallBean
import com.haoshuang.zhouzhoubang.model.bean.YyBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class PersonalReworkViewModel : BaseViewModel() {

    /**
     * 待确认数据信息
     */
    val confirmOrderTimeData = StatefulMutableLiveData<ResponseBean<YyBean>>()
    fun confirmOrderTime(orderId: String) = netRequest {
        start { confirmOrderTimeData.value = StateData.Loading }
        request { ApiRepo.confirmOrderTime(orderId) }
        success { confirmOrderTimeData.value = StateData.Success(it) }
        error { code, msg ->
            confirmOrderTimeData.value = StateData.Error(code, msg)
        }
    }

    /**
     * 同意返工
     */
    val masterAgreeReworkData = StatefulMutableLiveData<ResponseBean<Any>>()
    fun masterAgreeRework(
        original_id: String,
        service_day: String,
        service_time: String,
        team_leader: String = "",
        team_member: String = ""
    ) = netRequest {
        start { masterAgreeReworkData.value = StateData.Loading }
        request {
            ApiRepo.masterAgreeRework(
                original_id,
                service_day,
                service_time,
                team_leader,
                team_member
            )
        }
        success { masterAgreeReworkData.value = StateData.Success(it) }
        error { code, msg ->
            masterAgreeReworkData.value = StateData.Error(code, msg)
        }
    }
}